package com.four.reimbursemanage.controller;

import com.four.reimbursemanage.common.bean.ResponseData;
import com.four.reimbursemanage.common.controller.BaseController;
import com.four.reimbursemanage.entity.OutmoneyApply;
import com.four.reimbursemanage.entity.Payapply;
import com.four.reimbursemanage.service.IPayapplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 支付申请Controller
 * 
 * @author lwy
 */
@RestController
@CrossOrigin
@RequestMapping("/payapply")
public class PayapplyController extends BaseController
{
    @Autowired
    private IPayapplyService payapplyService;

    /**
     * 查询支付申请列表
     */
    @GetMapping("/payapplyList")
    public ResponseData<Object> getPayapply(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "department",required = false) String department,
            @RequestParam(value = "transactor",required = false) String transactor,
            @RequestParam(value = "payee",required = false) String payee,
            @RequestParam(value = "paymoney",required = false) String paymoney,
            @RequestParam(value = "type",required = false) String type,
            @RequestParam(value = "month",required = false)@DateTimeFormat(pattern = "yyyy-MM-dd")  Date month,
            @RequestParam(value = "state",required = false) Integer state
    ){
        return returnObject(payapplyService.getOnrePage(pageNum, pageSize, department, transactor, payee, paymoney, type, month, state));
    }

    /**
     * 查询本人支付申请列表
     */
    @GetMapping("/selectByNum")
    public ResponseData<Object> getPayapply(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "applyDepartment",required = false) String applyDepartment,
            @RequestParam(value = "transactor",required = false) String transactor,
            @RequestParam(value = "payee",required = false) String payee,
            @RequestParam(value = "paymoney",required = false) String paymoney,
            @RequestParam(value = "type",required = false) String type,
            @RequestParam(value = "month",required = false)@DateTimeFormat(pattern = "yyyy-MM-dd")  Date month,
            @RequestParam(value = "state",required = false) Integer state,
            @RequestParam(value = "number",required = false) String number
    ){
        return returnObject(payapplyService.getOnrePageUser(pageNum, pageSize, applyDepartment, transactor, payee, paymoney, type, month, state, number));
    }

    /**
     * 获取支付申请详细信息
     */
    @GetMapping(value = "/selectById")
    public ResponseData<Object> getInfo(@PathVariable("id") Integer id)
    {
        Payapply payapply=payapplyService.selectPayapplyById(id);
        return returnObject(payapply);
    }

    /**
     * 新增支付申请
     */

    @PostMapping("/add")
    public ResponseData<Boolean> add(Payapply payapply)
    {
        return returnBoolean(payapplyService.insertPayapply(payapply));
    }

    /**
     * 修改支付申请
     */

    @PutMapping("/update")
    public ResponseData<Boolean> edit(@RequestBody Payapply payapply)
    {
        return returnBoolean(payapplyService.updatePayapply(payapply));
    }

    @PutMapping("/updateC")
    public ResponseData<Boolean> updateS(@RequestBody Payapply payapply)
    {
        return returnBoolean(payapplyService.updateC(payapply));
    }

    /**
     * 删除支付申请
     */
   /*
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(payapplyService.deletePayapplyByIds(ids));
    }*/
}
